// https://vike.dev/onHydrationEnd
export { onHydrationEnd }

import type { OnHydrationEndAsync } from 'vike/types'
import useUserStore from '@/stores/useUserStore'
import cache from '@/utils/cache'

const onHydrationEnd: OnHydrationEndAsync = async (): ReturnType<OnHydrationEndAsync> => {
  console.log('Hydration finished; page is now interactive.')
  const useUser = useUserStore(); // 激活pinia
  const theme = cache.getTheme()||'light';
  document.querySelector('html')?.setAttribute('data-theme',theme)
  useUser.setTheme(theme)
}
